var fs = require('fs');
var PATH_USERS = '/users.json';

function log_user(username, password)
{
	var data = fs.readFileSync(__dirname + PATH_USERS, 'utf8');
	var ok = false;
	if(data)
	{
		var users = JSON.parse(data);
		for(var name in users)
		{
			if(username == name && users[name] == password)
				ok = true;
		}
	}
	else
		console.log('Could not read '+__dirname + PATH_USERS+'.');

	return ok;
}


exports.log_user = log_user;